<template>
  <div>
    <!-- 展示 -->
    <ul>
      <li v-for="(item, index) in LYB_list" :key="index">
        <h5>{{ item.title }}</h5>
        <p>{{ item.content }}</p>
      </li>
    </ul>
    <!-- 留言板 -->
    <input type="text" v-model="title" /><br />
    <textarea cols="20" rows="5" v-model="content"></textarea><br />
    <button @click="submit">留言</button>
  </div>
</template>
<script>
import { mapState } from "vuex";

export default {
  computed: {
    ...mapState(["LYB_list"]),
  },
  data() {
    return {
      title: "",
      content: "",
    };
  },
  methods: {
    submit() {
      console.log(this.title, this.content);
      this.$store.dispatch("setLYB_list", {
        title: this.title,
        content: this.content,
      });
    },
  },
};
</script>